home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_100 / 163_02 / strncmp.c < prev    next >
Text File  |  1988-01-30  |  512b  |  13 lines

  1. /*
  2. ** compare s1 and s2 for length n
  3. ** result is <, ==, or > 0 as s1 is <, ==, > s2
  4. */
  5. strncmp(s1, s2, n) char *s1, *s2; int n; {
  6.   while(n--) {
  7.     if(*s1 > *s2) return 1;
  8.     if(*s1 < *s2++) return -1;
  9.     if(!*s1++) return 0;
  10.     }
  11.   return 0;
  12.   }
  13.